<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        编写一个函数，计算两个数字的和、积 要求：使用传参的形式

        function test(a,b,type){
        
        }
    </div>
    <input type="text" id="num1">
    <select name="" id="calc">
        <option value="*">乘积</option>
        <option value="+">求和</option>
    </select>
    <input type="text" id="num2">
    <button id="btn">提交</button>
    <script>
        function plusMul (a,b,type) {
            var res = 0 ;
            if ( type == "+" ) {
                res = parseInt(a) + parseInt(b);
            } else if ( type == "*" ) {
                res = a * b ;
            } else {
                console.log("输入符号不符合规范");
            }
            console.log(res);
        }
        var num1 = document.getElementById("num1");
        var num2 = document.getElementById("num2");
        var calc = document.getElementById("calc");
        var btn = document.getElementById("btn");
        btn.onclick = function () {
            var a = parseInt(num1.value);
            var b = parseInt(num2.value);
            var type = calc.value;
            plusMul(a,b,type);
        }
    </script>
</body>
</html>